package com.bawei.demoa.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bawei.demoa.R;
import com.bawei.demoa.bean.NewsInfo;

import java.util.List;

/**
 * Created by Administrator on 2016/6/1 0001.
 */
public class MyAdapter extends BaseAdapter {

    private Context context;
    private List<NewsInfo> list;

    public MyAdapter(Context context, List<NewsInfo> list) {
        super();
        this.context=context;
        this.list=list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view=View.inflate(context, R.layout.list_item,null);
        TextView title = (TextView) view.findViewById(R.id.title);
        TextView info = (TextView) view.findViewById(R.id.info);
        TextView time = (TextView) view.findViewById(R.id.time);

        title.setText(list.get(position).getTitle());
        info.setText(list.get(position).getBody());
        time.setText(list.get(position).getPubDate());
        return view;
    }
}
